import request from '@/utils/request';
import { getUserInfo } from '@/utils/auth';

// 获取角色列表
export function getRoleListApi(postBody) {
  postBody.userId = getUserInfo().userId;
  return request({
    url: process.env.VUE_APP_SYS_SERVICE + 'api/sysRole/getSysRoleListByPage',
    method: 'post',
    data: postBody,
    disableLoading: true // 提示作用，以后默认为true
  });
}

// 根据code获取部门
export function getByCodeApi(postBody) {
  return request({
    url: process.env.VUE_APP_SYS_SERVICE + 'api/sysStruct/getByCode',
    method: 'get',
    params: {
      code: postBody
    },
    disableLoading: true // 提示作用，以后默认为true
  });
}

// 获取用户详情
export function getUserDetailApi(objectId) {
  let url = process.env.VUE_APP_SYS_SERVICE + 'api/sysUser/getUserDetails';
  return request({
    url: url,
    method: 'get',
    params: { objectId }
  });
}

// 创建或者编辑用户
export function createOrEditUserApi(user) {
  let url = process.env.VUE_APP_SYS_SERVICE + 'api/sysUser/create';
  if (user.objectId || user.objectId == 0) {
    url = process.env.VUE_APP_SYS_SERVICE + 'api/sysUser/update';
  }
  return request({
    url: url,
    method: 'post',
    data: user
  });
}

// 组织架构
export function getSysStructsTreeApi() {
  return request({
    url: process.env.VUE_APP_SYS_SERVICE + 'api/sysStruct/getSysStructsTree',
    method: 'get'
  });
}

// 查询字典
export function getDictionaryDataListApi(postBody) {
  postBody.userId = getUserInfo().userId;
  return request({
    url: process.env.VUE_APP_SYS_SERVICE + 'api/sysEnumDictionary/getSysEnumDictionaryListByPage',
    method: 'post',
    data: postBody
  });
}

// 查询职位分页列表
export function getSysPositionListByPageApi(postBody) {
  return request({
    url: process.env.VUE_APP_SYS_SERVICE + 'api/sysPosition/getSysPositionListByPage',
    method: 'post',
    data: postBody
  });
}

